﻿
@{
    ViewData["Title"] = "GridConf";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model List<EasyToHelp.Entity.GridManageField>
<blockquote class="layui-elem-quote layui-text">
    您正在操作的是【@ViewBag.BusinessName】
</blockquote>
<div style="width: 216px; margin: 0;">
    <button class="layui-btn layui-btn-fluid" onclick=" synTableManageField('@ViewBag.CodeName')">同步数据</button>
</div>
<div class="layui-form">
    <table class="layui-table">
        <thead>
            <tr>
                <th>序号</th>
                <th>标题</th>
                <th>字段</th>
                <th>类型</th>
                <th>业务码</th>
                <th>业务名称</th>
                <th>是否主键</th>
                <th>是否外键</th>
                <th>是否标题</th>
                <th>是否显示</th>
                <th>是否冻结</th>
                <th>是否排序</th>
                <th>排序</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @if (Model != null)
            {
                foreach (var item in Model)
                {
            <tr>
                <td>@item.Id</td>
                <td>@item.ChineseName</td>
                <td>@item.EnglishName</td>
                <td>@item.FieldType</td>
                <td>@item.CodeName</td>
                <td>@item.BusinessName</td>
                <td>@(item.IsPkName == true ? "是" : "否")</td>
                <td>@(item.IsFkName == true ? "是" : "否")</td>
                <td>@(item.IsSearchPkName == true ? "是" : "否")</td>
                <td>@(item.IsTitle == true ? "是" : "否")</td>
                <td>@(item.IsFixed == true ? "是" : "否")</td>
                <td>@(item.IsSort == true ? "是" : "否")</td>
                <td>@item.SortOrder</td>
                <td>
                    <button onclick="UpdateField('Id', @item.Id)" class="layui-btn layui-btn-warm layui-btn-xs">编辑</button>
                    <button class="layui-btn layui-btn-danger layui-btn-xs">删除</button>
                </td>
            </tr>
                }
            }

        </tbody>
    </table>
</div>
<script type="text/javascript">
    //同步数据
    function synTableManageField(TableName) {
        $.post("/GridManage/synTableManageField", { TableName: TableName },
            function (data) {
                layui.use('layer', function () {
                    var layer = layui.layer;
                    if (data.code == 100) {
                        layer.alert(data.msg, { icon: 6 }, function () {
                            window.location.reload();
                        }
                        );
                    }
                    else {
                        layer.alert(data.msg, { icon: 5 });
                    }
                });
            }, "json");
    }
    function UpdateField(fkname, fkvalue) {
        layui.use('layer', function () {
            var layer = layui.layer;
            layer.open({
                type: 2,
                title: "表单配置",
                shadeClose: true,
                shade: 0.8,
                maxmin: true, //开启最大化最小化按钮
                area: ['600px', '500px'],
                content: '/FormManage/FormView?TableName=gridmanagefield&FkName=' + fkname + '&FkValue=' + fkvalue + ''
            });
        });
    }
</script>